<?php
defined( 'BASEPATH' ) or exit( 'No direct script access allowed' );
class Links_model extends MY_Model
{
    function get_list_count($gid)
    {
        $this->_db->select( $this->_table, 'count(*)' );
        $this->_db->where( '`gid`=? and `deleted`=0', $gid );
        return ( int ) $this->_db->fetch_cell();
    }
    function get_list($gid, $length = 10, $begin = 0)
    {
        $this->_db->select( $this->_table, '`id`,`sub_id`,`target`,`uri`,`selected_uri`,`img_cover`,`title`,`subtitle`,`description`,`ext`,`sort`,`enable`' );
        $this->_db->where( '`gid`=? and `deleted`=0', $gid );
        $this->_db->order( '`sort` desc, `id`' );
        $this->_db->limit( $length, $begin );
        return $this->_db->fetch_all();
    }
    function get($id)
    {
        $this->_db->select( $this->_table );
        $this->_db->where( '`id`=? and `deleted`=0', $id );
        $this->_db->limit( 1 );
        return $this->_db->fetch_row();
    }
}